﻿using System;

namespace Mono.Cecil.Metadata
{
	// Token: 0x020000F7 RID: 247
	internal sealed class BlobHeap : Heap
	{
		// Token: 0x06000A10 RID: 2576 RVA: 0x00005984 File Offset: 0x00003B84
		public BlobHeap(byte[] data) : base(data)
		{
		}

		// Token: 0x06000A11 RID: 2577 RVA: 0x0002DCBC File Offset: 0x0002BEBC
		public byte[] Read(uint index)
		{
			bool flag = index == 0U || (ulong)index > (ulong)((long)(this.data.Length - 1));
			byte[] result;
			if (flag)
			{
				result = Empty<byte>.Array;
			}
			else
			{
				int num = (int)index;
				int num2 = (int)this.data.ReadCompressedUInt32(ref num);
				bool flag2 = num2 > this.data.Length - num;
				if (flag2)
				{
					result = Empty<byte>.Array;
				}
				else
				{
					byte[] array = new byte[num2];
					Buffer.BlockCopy(this.data, num, array, 0, num2);
					result = array;
				}
			}
			return result;
		}

		// Token: 0x06000A12 RID: 2578 RVA: 0x0002DD38 File Offset: 0x0002BF38
		public void GetView(uint signature, out byte[] buffer, out int index, out int length)
		{
			bool flag = signature == 0U || (ulong)signature > (ulong)((long)(this.data.Length - 1));
			if (flag)
			{
				buffer = null;
				index = (length = 0);
			}
			else
			{
				buffer = this.data;
				index = (int)signature;
				length = (int)buffer.ReadCompressedUInt32(ref index);
			}
		}
	}
}
